package com.ray.auth.common;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ray.auth.system.service.DictTypeService;
import com.ray.auth.system.service.MenuService;
import com.ray.auth.system.service.OrganizationService;
import com.zjhc.flyhong.common.datastructure.TreeNode;
import com.zjhc.flyhong.common.function.operator.LoginUser;
import com.zjhc.web.controller.WebController;

/**
 * <h1>通用树 控制器</h1>
 * 
 * @创建人 ray
 * @创建时间 2017-06-12
 * @版本 1.0
 * @重要修改备注
 * 
 */
@Controller
@RequestMapping("/treeController")
public class TreeController extends WebController{
	
 @Autowired	
 private MenuService menuService;	
 @Autowired	
 private DictTypeService dictTypeService; 
 @Autowired	
 private OrganizationService  organizationService;
 /**
 * 菜单异步树
 * @return
 */
@RequestMapping(value = "menuTree")
@ResponseBody
 public ResponseEntity<List<TreeNode>> menuTree(String id,Integer level){
	LoginUser loginUser = getLoginUser();
	List<TreeNode> treeList = menuService.queryMenuListByParentId(id,level,loginUser);
	return doSuccess(treeList); 
 }
/**
* 菜单异步树
* @return
*/
@RequestMapping(value = "myMenuTree")
@ResponseBody
public ResponseEntity<List<TreeNode>> myMenuTree(String id,Integer level){
	LoginUser loginUser = getLoginUser();
	List<TreeNode> treeList = menuService.queryMyMenuListByParentId(id,level,loginUser);
	return doSuccess(treeList); 
}


/**
* 字典类型异步树
* @return
*/
@RequestMapping(value = "dictTypeTree")
@ResponseBody
public ResponseEntity<List<TreeNode>> dictTypeTree(String id,Integer level){
	LoginUser loginUser = getLoginUser();
	List<TreeNode> treeList = dictTypeService.queryDictTypeListByParentId(id, level, loginUser);
	return doSuccess(treeList); 
}


/**
* 组织异步树
* @return
*/
@RequestMapping(value = "orgTree")
@ResponseBody
public ResponseEntity<List<TreeNode>> orgTree(String id,Integer level){
	LoginUser loginUser = getLoginUser();
	List<TreeNode> treeList = organizationService.queryOrgListByParentId(id, level, loginUser);
	return doSuccess(treeList); 
}

}
